package utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.shishi.tech.paipai.application.BaseApplication;

/**
 * 缓存信息
 *
 * @author Administrator
 */
public class SharedPreUtil {

    private static SharedPreferences sharePre;
    private static final String SHARED_NAME = "SHARED_NAME";

    /**APP基本数据*/
    public static SharedPreUtil sharePreUtil;
    /**UUID*/
    public static String UUID = "UUID";
    /**IM地址*/
    public static final String SHARED_IM_IP = "Ip";
    /**IM端口*/
    public static final String SHARED_IM_PORT = "Port";
    /**APP版本号*/
    public static final String VERSION_NAME = "versionName";
    /**APP版本号CODE*/
    public static final String VERSION_CODE = "versionCode";
    /**IM 是否登录 或者 重新登录 （IM登录成功true,主动退出帐号false）*/
    public static final String SHARED_IM_IS_RELOGIN = "isReLogin";
    /**通道自动检测关闭时，是否需要发起重连（false 不重连）*/
    public static final String SHARED_IM_IS_RECONNCENT = "reConnect";

    /**用户基本数据*/
    public static final String USER_ID = "USER_ID";
    /**用户token*/
    public static final String USER_TOKEN = "USER_TOKEN";
    /**用户电话号码*/
    public static final String USER_PHONE = "USER_PHONE";
    /**用户注册键入的临时电话号码*/
    public static final String USER_REGIS_TEMP_PHONE = "USER_REGIS_TEMP_PHONE";
    /**用户密码*/
    public static final String USER_PASSWORD = "USER_PASSWORD";

    /**用户位置详细*/
    public static final String USER_LOCATION_DETAIL = "USER_LOCATION_DETAIL";
    /**用户位置纬度*/
    public static final String USER_LOCATION_LAT = "USER_LOCATION_LAT";
    /**用户位置经度*/
    public static final String USER_LOCATION_LON = "USER_LOCATION_LON";
    /**认证是否完成certificat*/
    public static final String CERTIFICATIONSTATE = "certificationstate";
    /**聊天  转发时，保存转发的内容*/
    public static final String ClIP_Data = "ClIP_Data";
    /**微商资料*/
    public static final String MICORDETAIL_ENTITY = "MicroDetailEntity";
    /**个人基本资料*/
    public static final String USERDETAIL_ENTITY = "UserDetailEntity";
    /**通信录好友更新时间*/
    public static final String FRIEND_UDTIME = "Friend_updateTime";
    /**通信录企业好友更新时间*/
    public static final String ETP_UDTIME = "UpdateTime_Enterpraise";
    /**通信录微商好友更新时间*/
    public static final String MICRO_UDTIME = "Macro_Friend_updateTime";
    /**通信录关注微商好友更新时间*/
    public static final String MICRO_FANS_UDTIME = "Macro_fans_Friend_updateTime";

    /**弹框引导*/
    /**找工作*/
    public static final String JOB_CODE = "dialog_job";
    /**微商圈*/
    public static final String MIC_CODE = "dialog_mic";
    /**微商圈(个人打卡)*/
    public static final String MIC_PER_CODE = "dialog_mic_per";
    /**微商圈(微商打卡)*/
    public static final String MIC_MIC_CODE = "dialog_mic_mic";
    /**大图引导*/
    public static final String GUIDING_DATING = "guiding_dating";
    public static final String GUIDING_PUNSH = "guiding_punsh";
    public static final String GUIDING_TYPE = "type";
    /**强制引导*/
    /**被钱砸打卡*/
    public static final String GUIDING_PUNCH_CARD = "guiding_punch_card";
    /**被钱砸等级*/
    public static final String GUIDING_PUNCH_GRADE = "guiding_punch_grade";
    /**被钱砸评价*/
    public static final String GUIDING_PUNCH_EVALUATE = "guiding_punch_evaluate";
    /**微商进入*/
    public static final String GUIDING_MICRO_PUNCH = "guiding_micro_punch";
    /**微商被钱砸打卡*/
    public static final String GUIDING_MICRO_CARD = "guiding_micro_card";
    /**微商被钱砸添加客户*/
    public static final String GUIDING_MICRO_ADD = "guiding_micro_add";
    /**微商被钱砸添加购买*/
    public static final String GUIDING_MICRO_BUY = "guiding_micro_buy";
    /**进入找工作打卡*/
    public static final String GUIDING_WORK_PUNCH= "guiding_work_punch";
    /**找工作评价*/
    public static final String GUIDING_WORK_EVALUATE = "guiding_work_evaluate";
    /**找工作打卡*/
    public static final String GUIDING_WORK_CARD= "guiding_work_card";
    /**找工作简历*/
    public static final String GUIDING_WORK_RESUME= "guiding_work_resume";
    /**相亲感兴趣男*/
    public static final String GUIDING_DATA_INTEREST= "guiding_data_interest";
    /**相亲上传照片*/
    public static final String GUIDING_DATA_UPLOAD= "guiding_data_upload";
    /**相亲设置马币*/
    public static final String GUIDING_DATA_MABI= "guiding_data_mabi";
    /**速闻行业*/
    public static final String GUIDING_NEWS_INDUESTRY = "guiding_news_industry";

    /**控制是否是第一次进入首页（同时进入引导页提示）*/
    public static final String FIRST_LOGIN = "First_Login";

    /**获取服务端数据 行业数据*/
    public static final String SERVER_DATA_INDUESTRY = "SERVER_DATA_INDUESTRY";

    /**第三方缓存信息*/
    public static String USER_PHONENUMBER = "thirdtype";
    /**微商修改性别的时间,^^已废弃^^*/
    public static final String MERCHANT_UPDATE_SEX = "MERCHANT_UPDATE_SEX";

    /**被钱砸打卡声音开关*/
    public static final String PUNCH_CARD_VOICE_TOGGLE = "PUNCH_CARD_VOICE_TOGGLE";

    /**七牛 url*/
    public static final String QINIU_URL = "QINIU_URL";

    /**七牛 uptoken*/
    public static final String QINIU_TOKEN = "QINIU_TOKEN";

    /** 自定义表情的修改时间 */
    public static final String GOOD_EMOTIONS_LASTMODIFYTIME = "GOOD_EMOTIONS_LASTMODIFYTIME";

    /**速闻地区*/
    public static final String NEWS_TAB_CHECKED_AREA = "NEWS_TAB_CHECKED_AREA";

    /**系统配置*/
    public static final String SYSTEM_CONFIG = "SYSTEM_CONFIG";

    /** 消息模块的播报 总开关 .*/
    public static final String ANNOUNCE_ONOFF ="ANNOUNCE_ONOFF";

    private SharedPreUtil() {
    }

    public static SharedPreUtil getInstance() {
        return getInstance(BaseApplication.getInstance().getBaseContext());
    }

    public static SharedPreUtil getInstance(Context context) {
        if (null == sharePreUtil) {
            sharePreUtil = new SharedPreUtil();
            sharePre = context.getSharedPreferences(SHARED_NAME, Context.MODE_MULTI_PROCESS);
        }
        return sharePreUtil;
    }

    /**
     * putValue
     * @param key 参数描述
     * @return Object 返回对象描述
     * @Exception 异常描述
     */
    public void putValue(String key, String value) {
        Editor editor = sharePre.edit();
        editor.putString(key, value);
        editor.commit();
    }

    public void putValue(String key, int value) {
        Editor editor = sharePre.edit();
        editor.putInt(key, value);
        editor.commit();
    }

    public void putValue(String key, boolean value) {
        Editor editor = sharePre.edit();
        editor.putBoolean(key, value);
        editor.commit();
    }

    public String getValue(String key) {
        return sharePre.getString(key, "");
    }

    public int getIntValue(String key) {
        return sharePre.getInt(key, 0);
    }

    public boolean getBooleanValue(String key) {
        return sharePre.getBoolean(key, false);
    }
    public boolean getBooleanValueDT(String key) {
        return sharePre.getBoolean(key, true);
    }

    public boolean isContains(String key) {
        return sharePre.contains(key);
    }

    public void remove(String key) {
        Editor editor = sharePre.edit();
        editor.remove(key);
        editor.commit();
    }

}
